package com.itheima.controller;

import com.itheima.pojo.Emp;
import com.itheima.pojo.LoginInfo;
import com.itheima.pojo.Result;
import com.itheima.service.EmpService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author：cxl
 * @Package：com.itheima.controller
 * @Project：web-project
 * @name：LoginController
 * @Date：2025-09-30 9:08 am
 * @Filename：LoginController
 */
@Slf4j
@RestController

public class LoginController {
    @Autowired
    EmpService empService;

    /*员工登录*/
    @PostMapping("/login")
    public Result login(@RequestBody Emp emp) {
        LoginInfo loginInfo = empService.login(emp);

        if (null==loginInfo){
            return Result.error("用户名或密码不存在");
        }
        return Result.success(loginInfo);
    }
}
